package io.kimmking.dubbo.demo.consumer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.kimmking.dubbo.demo.consumer.model.DollarAccount;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author xiaogege
 * @since 2021-06-07
 */
public interface DollarAccountMapper extends BaseMapper<DollarAccount> {

    /**
     * 冻结美元
     *
     * @param userId
     * @param amount
     * @return
     */
    int freezeAmount(@Param("userId") String userId,
                     @Param("amount") BigDecimal amount);

    /**
     * 解冻美元
     *
     * @param userId
     * @param amount
     * @return
     */
    int unfreezeAmount(@Param("userId") String userId,
                       @Param("amount") BigDecimal amount);

    /**
     * 从冻结资金中扣除
     *
     * @param userId
     * @param amount
     * @return
     */
    int deductFromFrozen(@Param("userId") String userId,
                         @Param("amount") BigDecimal amount);



}
